<template>
	<!-- 添加弹框 -->
		<el-dialog  width="60%" title=""   visible :show-close="false" :modal-append-to-body="false" class="wrap" @close="cancel" :close-on-click-modal="false">
		<i class="el-icon-close close" @click="cancel" style="color: white;"></i>
	    <div class="bt">添加学生资料</div>
			<div class="search">
				<el-button  type="primary"  class="add" size="small" style="border-radius:13px;" :loading="searchLoading" @click="search" icon="el-icon-search" ></el-button>
					<div class="search-item">
							<el-input placeholder="请输入老师名称" v-model="vkeyword"  @keyup.enter.native="search" icon="search"></el-input>
					</div>
			</div>
			<el-table
					:data="dataList"
					border
					align="center"
					class="admin-table"
					>
					<!-- <el-table-column type="selection" width="55"></el-table-column> -->
					<div slot='empty'>
							<img src="../../../assets/img/empty.png" style="width:40px;vertical-align: middle;">
							<span style="vertical-align: middle;">暂时还没有内容哦!</span>
					</div>
					<el-table-column
							:prop="v.prop"
							:label="v.label"
							v-for="(v,index) in portTitleList"
							align="center"
							show-overflow-tooltip
							v-if="v.hide != 0"
							:formatter="v.formatter"
							:align="v.align || 'center'"
							:fixed="v.fixed"
							:class-name="v.columnStyle"
							:width="v.width"
							:min-width="v.minWidth"
							:header-align="v.headerAlign || 'center'"
							>
							<template scope="scope">
									<div slot="reference" :style="tableCellControl(scope)">
											{{ scope.row[scope.column.property] }}
									</div>
							 </template>
							 <!-- <template scope="scope">
									 <div slot="reference" >
											 <div style="width:80px;margin:0 auto" v-if="scope.column.property == 'zwm'" @click="componentsShow('info',scope)">
													 <img :src="scope.row.xb == '男' ? $store.state.sexImg.boy : $store.state.sexImg.girl"
													 style="width:20px;vertical-align:middle; float: left;"
													 v-if="scope.column.property == 'zwm'">
													 <span style="vertical-align:middle;">{{ scope.row[scope.column.property] }}</span>
											 </div>
											 <span style="vertical-align:middle;" v-else>{{ scope.row[scope.column.property] }}</span>
									 </div>
							 </template> -->
					</el-table-column>
		<el-table-column label="操作"  width="160" align="center">
							<template scope="scope">
									<!-- v-if="scope.row.qx == 'Y'"-->
									<el-button size="small" type="text"  @click="submit(scope)">添加</el-button>
									<!-- <el-button size="small" type="text" @click="componentsShow('singleDelete',scope)">删除</el-button> -->
							</template>
					</el-table-column>
			</el-table>
		<!-- </el-dialog> -->
	</el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
	export default {
		props: ['params'],
		data() {
			return {
				dataList: [],  //表格数据
				vkeyword:'',
				portTitleList: [

						{
								prop:'zwm',
								label:'老师名称',
								hide:1,
								align:'center',
								fixed:false,
								width:'',
								minWidth:'',
								headerAlign:'center',
								formatter: function(row,column) {}
						},
						{
								prop:'dh',
								label:'电话',
								hide:1,
								align:'center',
								fixed:false,
								width:'',
								minWidth:'',
								headerAlign:'center',
								formatter: function(row,column) {}
						},
						{
								prop:'cns',
								label:'数量',
								hide:1,
								align:'center',
								fixed:false,
								width:'',
								minWidth:'',
								headerAlign:'center',
								formatter: function(row,column) {}
						},

				]
			}
		},
		created() {
			this.search();//分页获取默认数据
			// alert(this.params)
		},
		methods: {
			search () {
		//查询搜索触发事件
				var logininfo = JSON.parse(localStorage.logininfo) ;
				var params3 = qs.stringify({
					xxid:logininfo.xxid,
				});
					this.searchLoading = true;
					this.axios.post(this.$store.state.api + 'ls/xzlstype',params3)
					.then( res => {
							console.log(res)
							let data = res.data.data;
							this.total = data.totalPage;
							this.dataList = data;
							this.searchLoading = false;
					}).catch( res => {
							console.log(res)
							this.searchLoading = false;
					})
			},
			submit(id) {
				this.$store.state.loading = true;
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					xsids:this.params+'',
					lsid:id.row.lsid
				});
				//执行
				this.axios.post(this.$store.state.api + 'xsly/zyfp', params3)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'syzl', cancel: false });
							this.$store.state.loading = false;
						} else {
							this.$emit('close', { type: 'syzl', cancel: false });
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.warning("服务器繁忙，请重试");
						//this.$emit('close', { type: 'syzl', cancel: false });
						this.$store.state.loading = false;
					})
			},



			cancel() {
				this.$emit('close', { type: 'syzl', cancel: true })
			},
			tableCellControl (scope) {
				//表格单元格控制CSS样式
						/*if (scope.row.id == 112 && scope.column.property == "iname") {
								return {
										color:"red",
								}
						}else{
								return {
										color:"green",
								}
						}*/
			 },
			componentsShow (type,data) { //显示组件
								console.log(type,data)
								for ( let i in this.portComponents ) {
										if (type == this.portComponents[i].type) {
												this.portComponents[i].toggle = true;
												this.portComponents[i].params = data;
												if (this.portComponents[i].data.type == 'single') {
														this.portComponents[i].data.index = data.row.id
												}else if(this.portComponents[i].data.type == 'multiple'){
														this.portComponents[i].data.index = this.multipleDelNum;
												}else{
														return;
												}
												return;
										}
								}
						},
						componentsHide (setting) { //关闭组件
								for ( let i in this.portComponents ) {
										if (setting.type == this.portComponents[i].type) {
											 this.portComponents[i].toggle = false;
											 if (this.portComponents[i].type=='bq'){
													if (!setting.cancel) {
														 for ( let b in setting.clist ) {

													 this.bqList.push( setting.clist[b]);
													}

													}
											 }else{
												if (!setting.cancel) {
												}
											 }
											 return;
										}
								}
						}
		}
	}
</script>
<style lang="less" scoped >
	.wrap {
		.search{
			width: 100%;
			margin-top: 10px;
			overflow: hidden;
			.search-item{
				width: 150px;
				margin-right: 10px;
				float: right;
			}
			.add{
				float: right;
			}
		}
		.admin-table{
			margin-top: 10px;
		}
		.bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top: 0;
			left: 0;
			// margin-top: -70px;
			background: #50BFFF;
			// margin-left: -20px;
			// margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
		.close{
				z-index: 10;
				position: absolute;
		}

}

</style>
